import Component native "java/awt/Component" import Contain native "java/awt/Container" import Panel native "java/awt/Panel" import Applet native "java/applet/Applet" import Font native "java/awt/Font" import Color native "java/awt/Color" import Graphics native "java/awt/Graphics" import Button native "java/awt/Button" import Event native "java/awt/Event" import Window native "java/awt/Window" import Frame native "java/awt/Frame" class public grtest extends Applet { private Font font; private Button b2; private Button b3; private Button b4; int act; constructor (){ super(); return; } public void init() { this.font = new Font("Helvetica", Font.BOLD, 48); this.b2 = new Button("kresli kruh"); (void)this.add(Component(this.b2)); this.b3 = new Button("kresli stvorec"); (void)this.add(Component(this.b3)); this.b4 = new Button("kresli ciaru"); (void)this.add(Component(this.b4)); this.act=0; return; } public void paint(Graphics g) { if(this.act==0){ g.setFont(this.font); g.setColor(Color.blue); g.drawString("uvodny text",50,100); } else if(this.act==2){ g.setColor(Color.red); g.fillOval(10,10,100,100); } else if(this.act==3){ g.setColor(Color.cyan); g.fillRect(10,10,100,100); } else if(this.act==4){ g.setColor(Color.magenta); g.drawLine(10,10,100,100); } return; } public boolean action(Event evt,Object arg){ if(evt.target==Object(this.b2)){ this.act=2;this.repaint(); return true; } else if(evt.target==Object(this.b3)){ this.act=3;this.repaint(); return true; } else if(evt.target==Object(this.b4)){ this.act=4;this.repaint(); return true; } return false; } }